/************************************************************************
                                                                     
   Xceed Ultimate ListBox for Silverlight                                                                                                                                            
   Copyright (C) 2010 Xceed Software Inc.    
                                                                     
   This program is provided to you under the terms of the GNU General Public  
   License version 2 as published by the Free Software Foundation. 
        
   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY, without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License along 
   with this program, if not, write to the Free Software Foundation, Inc., 
   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

   This program can be provided to you by Xceed Software Inc. under a
   proprietary commercial license agreement for use in non-Open Source
   projects. Visit Xceed.com to find the commercial edition of 
   Xceed Ultimate ListBox for Silverlight.                                    
                                                                      
 **********************************************************************/

using System;

namespace Xceed.Silverlight.Data
{
  public struct GroupCountQueryParameters
  {
    #region Constructor

    internal GroupCountQueryParameters( 
      SortRequest sort, 
      FilterRequest filter, 
      JumpRequest jump,
      FilterGroupRequest filterGroup,
      SkipRequest skipRequest,
      TakeRequest takeRequest ) 
      : this()
    {
      if( sort == null )
        throw new ArgumentNullException( "sort" );

      // Make sure the sort request has at least one SortDescription.
      if( sort.SortDescriptions.Count <= 0 )
        throw new ArgumentException( "The sort request must contains at least one SortDescription.", "sort" );

      // Make sure the group jump request is linked with the sort request.
      if( jump != null )
      {
        // The jump request cannot be more precise than the sort request.
        if( sort.SortDescriptions.Count < jump.Values.Count )
          throw new DataInternalException();
      }

      // Make sure the filter group request is linked with the sort request.
      if( filterGroup != null )
      {
        // The filter group request cannot be more precise than the sort request.
        if( sort.SortDescriptions.Count < filterGroup.Values.Count )
          throw new DataInternalException();
      }

      this.Sort = sort;
      this.Filter = filter;
      this.Jump = jump;
      this.FilterGroup = filterGroup;
      this.Skip = skipRequest;
      this.Take = takeRequest;
    }

    #endregion

    #region Sort Property

    public SortRequest Sort
    {
      get;
      private set;
    }

    #endregion

    #region Filter Property

    public FilterRequest Filter 
    { 
      get; 
      private set;
    }

    #endregion

    #region Jump Property

    public JumpRequest Jump
    {
      get;
      private set;
    }

    #endregion

    #region FilterGroup Property

    public FilterGroupRequest FilterGroup
    {
      get;
      private set;
    }

    #endregion

    #region Skip Property

    public SkipRequest Skip
    {
      get;
      private set;
    }

    #endregion

    #region Take Property

    public TakeRequest Take
    {
      get;
      private set;
    }

    #endregion
  }
}
